package lesson1;



public class BankApp {
    public static void main(String[] args) {
        System.out.println("Banking Application has started");
        
        //1) Create checking account
        CheckingAccount briansAccount = null;
        System.out.println("briansAccount ref has been initialized to null");
        
        //2) Examine the object lifecycle
        briansAccount = new CheckingAccount("brian", "5221113333", 100.0);
        // first the initializer then the constructor
        
        if(briansAccount != null){ // checks if the object is valid
            System.out.println(briansAccount); // the VM gives a real object
        }
        
        //3) Testing object equality
        // == versus .equals
        CheckingAccount bobsAccount = new CheckingAccount("bob", "7772228917", 5000.0);
        if(briansAccount == briansAccount){
            System.out.println("brian is brian");
        }
        
        if(bobsAccount == bobsAccount){
            System.out.println("bob is bob");
        }
        
        if(briansAccount == bobsAccount){       // compares memory addresses 
            System.out.println("brian is bob"); // should not be executed
        }
        
        printAccountInfo(briansAccount);
        printAccountInfo(bobsAccount);
        
        // Must define the equals function for CheckingAccount
        if(briansAccount.equals(bobsAccount)){ // data comparison
            System.out.println("brian EQUALS bob");
        }
        
        //4) Well formed objects
        // explicit constructor
        // equals and hashCode and toString
        
        //5) States and Behaviors to objects
        
    }
    
    private static void printAccountInfo(CheckingAccount ca){
        System.out.printf("%s, %s, %s \n", 
                          ca.getName(), 
                          ca.getSsn(), 
                          ca.getBalance());
    }
}
